const port = process.env.port || process.env.npm_config_port || 9528 // dev port
const path = require('path');

function resolve(dir) {
  return path.join(__dirname, dir)
}




module.exports = {
  publicPath: './',
  lintOnSave: false,
  productionSourceMap: false, // 清除 .map 文件
  css: {
    loaderOptions: {
      less: { javascriptEnabled: true }
    }
  },
  pwa: {

    iconPaths: {

      favicon32: 'favicon.ico',

      favicon16: 'favicon.ico',

      appleTouchIcon: 'favicon.ico',

      maskIcon: 'favicon.ico',

      msTileImage: 'favicon.ico'

    }

  },
  chainWebpack(config) {
    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  },


  devServer: {
    port: port,
  }
}
